home *** CD-ROM | disk | FTP | other *** search
- /*
- File: CAttribute.h
-
- Contains: xxx put contents here xxx
-
- Written by: Tim Harnett
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <5> 3/6/95 TMH adapt to use Symantic compiler
- <4> 2/27/95 TMH adapt to use ETO16 universal headers
- <3> 2/14/95 CL remove globals
- <2> 12/12/94 TMH added default tag argument value
- <1> 9/20/94 TMH Abandon RoadsideRest embrace Mercury
- 4/5/94 TMH xxx put comment here xxx
-
- To Do:
- */
-
-
- #ifndef __CAttribute__
- #define __CAttribute__
-
- class CRecordID;
-
- #ifndef __BaseTypes__
- #include "BaseTypes.h"
- #endif
-
- #ifndef __CRString__
- #include "CRString.h"
- #endif
-
- #ifndef __OCEAUTHDIR__
- #include "OCEAuthDir.h"
- #endif
-
-
- const long kToolBoxAttrOverHead = 256; // plenty?
- const long kDefaultBuffSize = 1000+kToolBoxAttrOverHead; // plenty?
-
-
- /*
- A very simple class that is binary compatible, (but easier to use) with Attribute
- as defined in OCE.h
-
- */
-
- //----------------------------------------------------------------------------------------
- // C A t t r i b u t e
- //----------------------------------------------------------------------------------------
-
- typedef pascal OSErr (*CAttributeValueCallBack) (long clientData, const Attribute* attrValue);
-
-
- class CAttribute {
- public:
- CAttributeType fAttributeType;
- AttributeCreationID fCID;
- AttributeTag fTag;
-
- unsigned long fDataLength;
- void* fBytes;
-
-
- CAttributeValueCallBack fValueCallBack;
- long fClientData;
- OSErr fCallBackError;
-
-
- operator const Attribute*() const;
- operator Attribute*();
-
- CAttribute();
- CAttribute(Attribute* attr);
- CAttribute(CAttribute* attr);
- CAttribute(CAttributeType& attrType,AttributeTag tag,CreationID *cid = nil);
- CAttribute(short attrTypeIndex, AttributeTag tag='bnry', CreationID *cid = nil);
- CAttribute(char* attrType, AttributeTag tag='bnry', CreationID *cid = nil);
- CAttribute(AttributeTypePtr attrType, AttributeTag tag='bnry', CreationID *cid = nil);
-
-
- ~CAttribute();
-
- CreationID CID();
- CAttributeType& Type();
- AttributeTag Tag();
-
- void SetType(short attrTypeIndex);
-
- OSErr AddAttribute(CRecordID& rid,AddrBlock *serverHint=nil, AuthIdentity identity = 0);
- OSErr ChangeValue(CRecordID& rid,AddrBlock *serverHint=nil, AuthIdentity identity = 0);
- OSErr DeleteValue(CRecordID& rid,AddrBlock *serverHint=nil, AuthIdentity identity = 0);
-
- OSErr VerifyValueCID(CRecordID& rid,AddrBlock *serverHint=nil, AuthIdentity identity = 0);
-
- OSErr Write1Value(CRecordID& rid,void* valueBuf, long valueBufSize, AuthIdentity identity = 0);
- OSErr Read1Value(CRecordID& rid, void* valueBuf, long* valueBufSize, AuthIdentity identity);
- OSErr Read1Value(CRecordID& rid, void* valueBuf, long valueBufSize, AuthIdentity identity); // for convenience
-
- OSErr LookupValues(CRecordID* recordID,CAttributeValueCallBack callBack,long clientData);
-
- static pascal Boolean __LookupValueCallBack(long clientData, const Attribute* attrValue);
-
- };
-
-
- // -- Constructors--
- inline CAttribute::CAttribute()
- {
- memset(this,0,sizeof(Attribute));
- fValueCallBack = 0;
- }
-
- inline CAttribute::CAttribute(Attribute* attr)
- {
- BlockMove((Ptr)attr,(Ptr) this,sizeof(Attribute));
- fValueCallBack = 0;
- }
- inline CAttribute::CAttribute(CAttribute* cattr)
- {
- BlockMove((Ptr)cattr,(Ptr) this,sizeof(Attribute));
- fValueCallBack = 0;
-
- }
-
- inline CAttribute::CAttribute(CAttributeType& attrType, AttributeTag tag, CreationID *cid)
- {
- fAttributeType = attrType; // copy
- fTag = tag;
- if (cid)
- OCECopyCreationID(cid, &fCID);
- else
- fCID.source = fCID.seq = 0;
-
- fDataLength = 0;
- fBytes = 0;
-
-
- fValueCallBack = 0;
- }
-
-
- inline CAttribute::CAttribute(char* attrType, AttributeTag tag, CreationID *cid)
- {
- fAttributeType = attrType; // copy
- fTag = tag;
- if (cid)
- OCECopyCreationID(cid, &fCID);
- else
- fCID.source = fCID.seq = 0;
-
- fDataLength = 0;
- fBytes = 0;
-
- fValueCallBack = 0;
- }
-
-
- inline CreationID CAttribute::CID() { return fCID; };
- inline AttributeTag CAttribute::Tag() { return fTag; };
- inline CAttributeType& CAttribute::Type() { return fAttributeType; };
-
- inline void CAttribute::SetType(short attrTypeIndex) { fAttributeType = (RString*) OCEGetIndAttributeType(attrTypeIndex); fCID.source = 0; fCID.seq = 0;};
-
- inline CAttribute::operator const Attribute*() const { return (const Attribute*) this; };
- inline CAttribute::operator Attribute*() { return (Attribute*) this; };
-
- inline OSErr CAttribute::Read1Value(CRecordID& rid, void* valueBuf, long valueBufSize, AuthIdentity idendtity) { return this->Read1Value(rid,valueBuf,&valueBufSize, idendtity); };
-
-
-
- #endif __CAttribute__
-